package com.bandi.tharshesnows.persistence;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class ApplicationPreferences {

	private static final String PREFS_NAME = "THAR_SHE_SNOWS_PREFS";
	private SharedPreferences prefs;
	private static ApplicationPreferences INSTANCE;
	private static final String KEY_FIRST_START = "first_start";

	private ApplicationPreferences(Context ctx) {
		prefs = ctx.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
	}

	public static void init(Context ctx) {
		if (INSTANCE == null) {
			INSTANCE = new ApplicationPreferences(ctx);
		}
	}

	public static ApplicationPreferences getPreferences() {
		if (INSTANCE == null) {
			throw new IllegalStateException(
					"ApplicationPrefernces has not been initialized.");
		}
		return INSTANCE;
	}

	public boolean isFirstStart() {
		return prefs.getBoolean(KEY_FIRST_START, true);
	}
	
	public void setFirstStart(boolean isFirstStart){
		Editor editor = prefs.edit();
		editor.putBoolean(KEY_FIRST_START, isFirstStart);
		editor.commit();
	}
}
